package com.hh.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hh.entity.domain.UserBehavior;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
* @author hanhui
* @description 针对表【user_behavior】的数据库操作Mapper
* @createDate 2025-07-25 21:40:38
* @Entity generator.domain.UserBehavior
*/
public interface UserBehaviorMapper extends BaseMapper<UserBehavior> {

    @Select("SELECT DISTINCT itemId FROM user_behavior WHERE userid = #{userId}")
    Set<Long> selectInteractedItems(@Param("userId") Long userId);

    @Select("SELECT itemId FROM user_behavior WHERE userId = #{userId} " +
            "ORDER BY timestamp DESC LIMIT #{limit}")
    List<Long> selectRecentItems(@Param("userId") Long userId, @Param("limit") int limit);

    @Select("SELECT * FROM user_behavior WHERE timestamp >= #{cutoff}")
    List<UserBehavior> selectAfterDate(@Param("cutoff") Date cutoff);
}




